/**
 *!function h5音乐播放器 练习项目
 *!author:wangTao
 *!version:
**/
window.onload = function (){
		
		function bfq (){
			var main = document.getElementById('main'),	//主体框架
				listContent = document.getElementById('listContent'), //ul父级				
				my_top_animate = document.getElementsByClassName('my_top_animate'),	//移动元素
				my_left_animate = document.getElementsByClassName('my_left_animate'),	//移动元素
				listContentUl = document.getElementById('listContentUl'), // 歌曲列表ul
				audio1 = document.getElementById('audio1'),	//播放器
				list_audio = document.getElementsByClassName('list_audio')[0],
				list_audio1 = document.getElementsByClassName('list_audio1')[0],
				Img = list_audio.getElementsByClassName('list_audioImg')[0], //播放图片
				defaultClass = Img.className,	//默认class
				details_GeName = document.getElementsByClassName('details_GeName')[0],
				GeNameH3 = details_GeName.getElementsByTagName('h3')[0],
				GeNameP = details_GeName.getElementsByTagName('p')[0],
				Title = list_audio.getElementsByClassName('title')[0], // 打开歌词详情
				Name = list_audio.getElementsByClassName('name')[0], //播放歌手
				details_audioPro = document.getElementsByClassName('details_audioPro')[0], //进度
				detailsAudioProUp = document.getElementById('detailsAudioProUp'), //进度条
				detailsAudioProBar = document.getElementById('detailsAudioProBar'), //进度圆球
				leftTime = document.getElementById('detailsNowTime'), //歌词详情left time 
				rightTime = document.getElementById('detailsAllTime'), //歌词详情right time 
				detailsPlay = document.getElementById('detailsPlay'), //歌词详情播放				
				list_audioBtn = document.getElementsByClassName('list_audioBtn')[0],
				list_audioBtnClass = list_audioBtn.className,
				musicDetails = document.getElementById('musicDetails'), // 歌词详情
				details_title = musicDetails.getElementsByClassName('details_title')[0], // 关闭歌词详情
				detailsLyricUl = document.getElementById('detailsLyricUl'),
				musiXieZhen = document.getElementsByClassName('musiXieZhen')[0],
				details_xz = document.getElementsByClassName('details_xz')[0],		
				
				listTitle = document.getElementById('listTitle'),
				
				my_play_list = document.getElementsByClassName('my_play_list')[0], //播放列表
				my_play_phb = document.getElementsByClassName('my_play_phb')[0], //排行榜
				
				my_bendi = document.getElementsByClassName('my_bendi')[0],	//本地音乐
				my_zaixian = document.getElementsByClassName('my_zaixian')[0],	//测试在线音乐

				my_lunb = document.getElementById('my_lunb'), //在线音乐轮播
				
			
				
				nav = document.getElementById('nav'),
				navLi = nav.getElementsByTagName('li'),
				
				prev = document.getElementById('detailsPrev'),
				next = document.getElementById('detailsNext'),
				
				tishi = document.getElementById('tishi');
 
				
			var upY = 0, //记录上一次滚动位置
				upX = 0, //记录上一次滚动位置
				upXl = 0, //记录上一次滚动位置
				upXX = 0, //记录上一次滚动位置 轮播
				moveLeft = 0, //左滑 计数
				lictH = listContent.offsetHeight,
				viewH = main.offsetHeight,
				viewW = main.offsetWidth,
				offGq = true,
				offLq = true,
				upG = '', //记录上一首歌曲 路径
				csrc = null ,	//歌曲路径
				timer = null,
				timer1 = null,
				jdt  = '',
				isNA = null,
				scale = null,
				Gemax = 0,
				xieZheni = 0,
				navColor = '#268ed7',
				arr = {},
				ultop = 60, //ul 列表默认top 
				ulttop = 160, //ul 列表top 
				//appMusic = 'http://topic.cn-lbjh.com/music/'; //项目目录
				appMusic = 'http://localhost/Music'; //项目目录
 
			//初始化
			function init(){
				//我的音乐
				myMusic();
				//在线音乐轮播
				myMusicLb();

				//滑动组件
				moveScroll(my_top_animate,my_left_animate);
				
				//底部歌曲组件
				bootGe();
				
				//默认值
				navLi[0].style.color = navColor;
				
				//初始化数据 
				dataload();
				
			}
			
			function dataload(){
				//分享音乐数据
				var my_tuijian = document.getElementsByClassName('my_tuijian')[0],
					listdl = document.getElementById('listdl'),
					list_content = document.getElementsByClassName('list_content')[0],
					musiccount = document.getElementById('musiccount');
				
				//排行榜
				musiccount.addEventListener('touchend',function (){
					defaultStyle(my_play_phb);
				},false)
				
				ajax({
					url : 'Share/ajax',
					success : function (data){
						
						var dl = '';
						for(var i =0; i < data.length; i++){
							dl += "<dl class='clear' mid="+data[i].id+"><dt><img src="+appMusic+data[i].sharepic+" /></dt><dd><h3>"+data[i].sharename+"</h3><p>"+data[i].shareintroduce+"</p></dd></dl>";
						}
						my_tuijian.innerHTML = dl;
						
						dls = my_tuijian.getElementsByTagName('dl');
						
						for(var i =0; i <dls.length; i++){
							dls[i].i = i;
							dls[i].addEventListener('touchend',function (){
								if(offGq){
								var id = this.getAttribute('mid');
 
								ajax({
									url :　'Share/ajaxJoin/id/'+id,
									success : function (data){
										listTitle.getElementsByTagName('h3')[0].innerHTML = data[0].sharename;
										var dl = "<dl class=clear><dt><img src="+appMusic+data[0].sharepic+" /></dt><dd>"+data[0].shareintroduce+"</dd></dl>";
										listdl.innerHTML = dl;

										list_content.style.top = ulttop +'px';	
										musicLoad(data);
										
										defaultStyle(my_play_list);
									}
								})
								}
							},false)
						}
						
					}
				})
				
				function defaultStyle(obj){
					obj.style.transition = '.2s';
					obj.style.transform = 'translate3d('+(0)+'px,0,0)';
					lictH = list_content.offsetHeight;
				}
				
				function musicLoad(data){
					for(var i =0; i < data.length; i++){
							var html='';
								for(var i =0; i <data.length; i++){
									html += "<li mid="+data[i].id+"><h3 class='title'>"+data[i].musicname+"</h3><p class='name'>"+data[i].authorname+"</p></li>";					 
								}
				 
									listContentUl.innerHTML = html;
									var li = listContentUl.getElementsByTagName('li');
													
										
									//选择歌曲
									selectGq(li);
									//歌词详情组件
									lyrics(li); 
								}
				}
				var li = {};
				lyrics(li);
				/*
				ajax({
					url : 'Music/ajax',
					success : function (data){
						if(offGq){
						 musicLoad(data);
						}
					}
				})
				*/
				/*
				touched(my_zaixian,ajax({
					url : 'Music/ajax',
					success : function (data){
						if(offGq){
						 musicLoad(data);
						}
					}
				}));
				 
				
				
				function touched(obj,fun){
					obj.addEventListener('touchend',function (){
					if(!offLq){return false;}
					listTitle.getElementsByTagName('h3')[0].innerHTML = obj.getAttribute('text');
						
					listdl.innerHTML='';
					list_content.style.top = ultop +'px';
					lictH = list_content.offsetHeight;
					fun;
					},false)
				}
				
				*/
			}
			
			

			function myMusicLb(){

				var yd = my_lunb.getElementsByClassName('my_lunb_yd')[0],
					imgs = yd.getElementsByTagName('img'),
					i =0,
					j = 0,
					js = 0,
					set = null,
					hov = 'my_lhov',
					max = imgs[0].offsetWidth*imgs.length;
					my_lunb.style.height = imgs[0].offsetHeight+'px';
					
				var ul = node('ul');
					
					my_lunb.appendChild(ul);
			
					for(;j<imgs.length; j++){
						ul.appendChild(node('li'));
					}
				var li = ul.getElementsByTagName('li');
					li[0].className = hov;
					
				 
						
					function node(obj){
						var nodes = document.createElement(obj);
							return nodes;
					}
					
					yd.appendChild(imgs[0].cloneNode(true));
					
					for(;i<imgs.length; i++){
						imgs[i].style.left = i*100+'%';
					}
					
					
					
					yd.style.transition = '.2s';
					
					clearInterval(set);
					set = setInterval(timeyd,2000);	
					function timeyd(){
						js ++;		
						if(js>imgs.length-1){
							 
							for(var z=0;z<li.length; z++){
								li[z].className = '';
								
							}
							
							yd.style.transition = '';
							yd.style.transform = 'translate3d('+ -(0)+'px,0,0)';
							
							//不写延迟 上和下会一起触发，达不到无缝效果
							js = 1; 
							setTimeout(function (){
								li[js].className = hov;
								yd.style.transition = '.2s';
								yd.style.transform = 'translate3d('+ -(js*yd.offsetWidth)+'px,0,0)';
							},10)
							
						}else{
							for(var z=0;z<li.length; z++){
								li[z].className = '';
								
							}
							if(js==imgs.length-1){
								li[0].className = hov;
							}else{
								li[js].className = hov;
							}
							
							yd.style.transition = '.2s';
							yd.style.transform = 'translate3d('+ -(js*yd.offsetWidth)+'px,0,0)';
						}		
										
						 
							
					 
							
					 
						
					}
					
					 
			}
			
			function myMusic(){
				var moveX,
					downX,
					liulH;
									
				my_play_list.style.transform = 'translate3d('+(viewW)+'px,0,0)';	
				my_play_phb.style.transform = 'translate3d('+(viewW)+'px,0,0)';	
					play_yd(my_play_list);
					play_yd(my_play_phb);
				function play_yd(obj){
					//左右手势
						obj.addEventListener('touchstart',function (e){
							this.style.transition = '';
							e.preventDefault();
							downX = e.touches[0].pageX;
							this.upX= 0;
							offLq = true;
						},false)
						
						obj.addEventListener('touchmove',function (e){		
 				
				 
							e.preventDefault();	
							//如果歌曲内容过少，取消滑动	
							//if(lictH >= liulH){return false;}
							upXl = upXl == undefined ? 0 : upXl;
 
							moveX = e.touches[0].pageX;
							
							//有的设备 不移动 也会触发移动 如果移动较少 不执行手势
							if(moveX-downX <= 20 && moveX-downX　>=0 || moveX-downX>=-20 && moveX-downX<=0){
								
								return false;
							} 
							
							var mXdXuX = moveX-downX+upXl;
							
							this.style.boxShadow = '0 0 50px #e6e6e6';
							
							 
							//判断是否超出right
							if(mXdXuX<= 0){
								
								mXdXuX = 0;
							}

							this.style.transform = 'translate3d('+(mXdXuX)+'px,0,0)';

							//记录上一次滚动位置
							this.upX = mXdXuX;
						},false)
							
						obj.addEventListener('touchend',function (e){
 
								e.preventDefault();
 
								//有的设备 不移动 也会触发移动 如果移动较少 不执行手势
								if(moveX-downX <= 20 && moveX-downX　>=0 || moveX-downX>=-20 && moveX-downX<=0){
									return false;
								} 
				
								//上一次位置赋值
								upXl = this.upX;

					 
								 
								//滑动3/1 回滚动画
								if(upXl <= 200) {
									this.style.transition = '.2s';
									this.style.transform = 'translate3d('+(0)+'px,0,0)';
									upXl = 0;
								}
								
								if(upXl >= 200){
									this.style.transition = '.2s';
									this.style.transform = 'translate3d('+(viewW)+'px,0,0)';
									upXl = viewW;
									lictH = listContent.offsetHeight;
								}
								upXl = 0;
								//是否超出right
								//else if(upY<=lictH-liulH){
									//this.style.transition = '.2s';
									//this.style.transform = 'translate3d(0,'+(lictH-liulH)+'px,0)';
								//	upY = lictH-liulH;
								//}
								 
						},false)
						
						
						//过度动画执行完毕 清除
						obj.addEventListener('transitionend',function (){
							this.style.boxShadow = '';
							this.style.transition = '';
						})
						
				}
	
				
						
						
				
			}
			
			function lyrics (li){

					musicDetails.style.transform = 'translate3d(0,'+(viewH)+'px,0)';		
				
					
					
					//关闭歌词详情
					details_title.addEventListener('touchend',function (){
						sp(viewH);
					},false)
	 
					//打开歌词详情
					list_audio1.addEventListener('touchend',function (){	
 
						if(upG){
							sp(0);
						}
					},false)
					
					
					//写真开关
					var de_xz = details_xz.className;
					details_xz.addEventListener('touchend',function (){

						 if(musiXieZhen.style.display == '' || musiXieZhen.style.display == 'block'){
							 this.className = '';
							 musiXieZhen.style.display = 'none';
							 tishi.style.opacity = 1;
							 tishi.innerHTML = '写真关闭';
						 }else{ 
							 this.className = de_xz;
							 musiXieZhen.style.display = 'block'
							 tishi.style.opacity = 1;
							 tishi.innerHTML = '写真打开';
						 }
						 clearInterval(this.set);
						 this.set = setTimeout(function (){
							 tishi.style.opacity = 0;
						 },1000)
						 
					},false)
					
					
					Gejind(li);
								
			}
			
			//歌曲 进度  快进 上下歌曲
			function Gejind(li){
				
				detailsPlay.className = 'details_playz';
				
					
					//快进歌曲
					detailsAudioProBar.addEventListener('touchstart',function (e){
						var disX = e.touches[0].pageX - this.offsetLeft;
						clearInterval(timer1);
						this.addEventListener('touchmove',function (e){
							var L = e.touches[0].pageX - disX;
							if(L<=0){
								L = 0;
							}
							else if(L >= details_audioPro.offsetWidth){
								L = details_audioPro.offsetWidth;
							}
							this.style.left = L +'px';
							
							scale = L/details_audioPro.offsetWidth;
							
						},false)
						this.addEventListener('touchend',function (){
							audio1.currentTime = scale * audio1.duration;
							timer1Jdt();
							GeCic(audio1.currentTime);
						},false)
					},false)
 	
			}
			
			//歌词处理
			function GeCi(Ge){
				//正则匹配
				var re = /\[[^[]+/g;
				arr = Ge.match(re) || {};
 
 
				function trim(str){ //删除左右两端的空格
　　  			   return str.replace(/(^\s*)|(\s*$)/g, "");
　　			}				
				

				for(var i =0; i< arr.length; i++){
					arr[i] = [formatTime(arr[i].substring(0,10)),trim(arr[i].substr(10))];
				}
 
				for(var i =0; i<arr.length; i++){		
					var lis =  "<li>"+arr[i][1]+"</li>";
						detailsLyricUl.innerHTML += lis;
				}
					lins = detailsLyricUl.getElementsByTagName('li');
					lins[0].className = 'active';
	 
				function formatTime(num){
					num = num.substring(1,num.length-1);
					var ar = num.split(':');
						return (parseFloat(ar[0]*60) + (+parseFloat(ar[1]).toFixed(2)));
				}

			}
	　　 	
			function GeCic(c){
				if(arr.length != undefined){
 
					var hei = lins[0].offsetHeight;
					var n = 0;
					for(var i =0; i<arr.length; i++){

						if( i!= arr.length - 1 && c > arr[i][0] && c < arr[i+1][0]){
							for(var j = 0; j < arr.length;j ++){
								lins[j].className = '';
							}
							lins[i].className = 'active';	
							
	  
							if(i > 5){
								var H = lins[i].offsetHeight ;
									Gemax = -((i-5)*hei);
								if(H == hei){
			 
									detailsLyricUl.style.transform = 'translate3d(0px, '+Gemax+'px, 0px)';
								}  
								
							}
							
						}else{
							
						}
									
					}
				}	
				 	
			}
			
			
			
			function timer1Jdt(){
				clearInterval(timer1);
				timer1 = setInterval(zdjdt,1000);
				
				//bug  不写延迟，获取不到歌曲time
				clearInterval(timer);
				timer = setInterval(rightTimeMax,10)		
			}
			
			function zdjdt(){
				jdt = audio1.currentTime/audio1.duration;
				leftTime.innerHTML = ymd(audio1.currentTime);
				detailsAudioProUp.style.width = jdt*details_audioPro.offsetWidth + 'px';
				detailsAudioProBar.style.left = jdt*details_audioPro.offsetWidth + 'px';
				GeCic(audio1.currentTime);
			}
			
			function rightTimeMax(){
				if(!isNaN(isNA=audio1.duration)){
						rightTime.innerHTML = ymd(isNA);		
						clearInterval(timer);
				}
						
			}
					
			
			function ymd(num){
				var is = parseInt(num);
				var m = toZero(Math.floor(is%3600/60));
				var s = toZero(Math.floor(is%60));
				return m +':'+s;
			}
									
			function toZero(num){
				if(num<=9){
						return '0' + num;
				}else{
						return '' + num;
				}							
			}
			
			function sp (h){				 	
				musicDetails.style.transition = '.2s';			
				musicDetails.style.transform = 'translate3d(0,'+(h)+'px,0)';		
			}		
			
			//选择歌曲
			function selectGq (li){
				var athis = {};
					for(var i =0; i<li.length; i++){
						li[i].i = i;
						li[i].addEventListener('touchend',function (){ 
						//	alert(offGq);
							athis = this;
							if(offGq){
								
								load(this,li);
								
							}
							
							 
 	
							//上一首
							prev.addEventListener('touchstart',function (){
								athis.i--;
								athis.i = athis.i < 0 ? li.length -1 : athis.i;	
							
								load(li[athis.i],li);
							},false)
							
							//下一首
							next.addEventListener('touchstart',function (){
								Next();	
							},false)
							//播放完毕，自动 下一首
							audio1.addEventListener('ended',function (){
								 Next();
							},false)
							
					
							
					function Next(){
								athis.i++; 
								athis.i = athis.i > li.length -1  ? 0 : athis.i;	
 							
								load(li[athis.i],li);
							}
							
							
						},false)
						
						
						
					}
						
			}
			
			
			
			//载入歌曲
			function load(obj,li){
				for(var i =0; i<li.length; i++){
					li[i].className = '';
				}
				obj.className = 'active';
									
				csrc = obj.getAttribute('mid');
				if(upG == csrc){
				//播放歌曲
					 playPaused();
				}else{
					
					upG = obj.getAttribute('mid');
					detailsPlay.className = 'details_playz';	
					
					
					list_audioBtn.style.display = 'block';
					list_audioBtn.className = list_audioBtnClass+' list_audioBtnPause';	
					
					GeNameH3.innerHTML = Title.innerHTML = obj.getElementsByTagName('h3')[0].innerHTML;
					GeNameP.innerHTML = Name.innerHTML = obj.getElementsByTagName('p')[0].innerHTML;
					Img.className = defaultClass+' move';
					
					detailsLyricUl.style.transform = 'translate3d(0px, '+0+'px, 0px)';
					
					var id = obj.getAttribute('mid');
 			
					ajax({
						url : 'Music/ajax/id/'+id,
						success : function (data){

							audio1.src = appMusic+data[0].music;
							Img.src =  appMusic+data[0].authorpic;
		
							//清除歌词
							arr = {};
							detailsLyricUl.innerHTML = '';
							if(data[0].musiclyric!=''){
								GeCi(appMusic+data[0].musiclyric);
							}
							
							//写真
							var img = '';
							for(var i =0; i< data[0].authorimg.length; i++){
								img += "<img src="+appMusic+data[0].authorimg[i]+" />";		
							}
							
							musiXieZhen.innerHTML = img;
							var imgs = musiXieZhen.getElementsByTagName('img');
							
							for(var i =0; i< imgs.length; i++){
								imgs[i].style.opacity = 0;
							}
							
							imgs[0].style.opacity= 1;
							
							clearInterval(musiXieZhen.set);
							musiXieZhen.set = setInterval(xieZhen,5000);
							
							function xieZhen(){
								xieZheni ++;
								xieZheni = xieZheni>imgs.length -1 ? 0 : xieZheni;
								for(var i =0; i< imgs.length; i++){
									imgs[i].style.opacity = 0;
								}
								imgs[xieZheni].style.opacity = 1;
							}
							
							//播放歌曲
							playPaused();
						}
					});
				 
											
				}	
 				
			}
			
			
			function playPaused(){
 
					if(audio1.paused){
 
						audio1.play();
						list_audioBtn.className = list_audioBtnClass+' list_audioBtnPause';
						detailsPlay.className = 'details_playz';
						Img.className += ' move';
						timer1Jdt();
						detailsPlay.className = 'details_playz';
						
 
					}else{
						audio1.pause();
						Img.className = defaultClass;
						list_audioBtn.className = list_audioBtnClass+' list_audioBtnPlay';
						detailsPlay.className = 'details_play';
						
						clearInterval(timer1);
 
					}
 
			}
			
			function bootGe(){
				
				list_audioBtn.addEventListener('touchstart',function (){
					
					 playPaused();
					
				},false)
				
			}
			
			//暂停
			detailsPlay.addEventListener('touchend',function (){																
				playPaused();
			},false)
			
			function navF(){
				for(var j = 0; j < navLi.length; j++){
										navLi[j].style.color = '';
									}
 
									navLi[moveLeft].style.color = navColor;
			}
			
			function moveScroll(objTop,objLeft){
			 
				var moveY,
					downY,
					moveX,
					downX,
					i=0,
					liulH,
					objTopLen = 1,
					num = 0;
		
					function objLeftStart(e){
						this.style.transition = '';
							e.preventDefault();
							downX = e.touches[0].pageX;
							offLq = true;
					}
					function objLeftMove(e){
						e.preventDefault();
							
							//如果歌曲内容过少，取消滑动	
							//if(lictH >= liulH){return false;}
							upX = upX == undefined ? 0 : upX;
							moveX = e.touches[0].pageX;
							var mXdXuX = moveX-downX+upX;
							
							//有的设备 不移动 也会触发移动 如果移动较少 不执行手势
							if(moveX-downX <= 20 && moveX-downX　>=0 || moveX-downX>=-20 && moveX-downX<=0){
								offLq = true;
								return false;
							}else{
								offLq = false;
							}
							
							//判断是否超出left
							if(mXdXuX>=0){
								mXdXuX = 0;
							}
							//判断是否超出right
							if(mXdXuX<= -(objTopLen)*this.offsetWidth){
								
								mXdXuX = -(objTopLen)*this.offsetWidth;
							}

							this.style.transform = 'translate3d('+(mXdXuX)+'px,0,0)';

							//记录上一次滚动位置
							this.upX = mXdXuX;
					}
					//左右手势
					for(;i<objLeft.length;i++){
						objLeft[i].i =i;
						objLeft[i].addEventListener('touchstart',objLeftStart,false)

						objLeft[i].addEventListener('touchmove',objLeftMove,false)
						
						objLeft[i].addEventListener('touchend',function (e){
 
								e.preventDefault();
								
								//如果没有移动X 不执行离开手势
								if(moveX == undefined){ return false; } 
								//有的设备 不移动 也会触发移动 如果移动较少 不执行手势
								if(moveX-downX <= 20 && moveX-downX　>=0 || moveX-downX>=-20 && moveX-downX<=0){
									return false;
								} 
								
								//上一次位置赋值
								upX = this.upX;
 
								moveLeft ++;
								moveLeft = moveLeft>objTopLen ? objTopLen  : moveLeft;
								//滑动3/1 回滚动画
								if(upX >= (moveLeft*(-200)) ){
									this.style.transition = '.2s';
									this.style.transform = 'translate3d('+(0)+'px,0,0)';
									upX = 0;
									moveLeft --;
									navF();
								}else{
									 navF();
									this.style.transition = '.2s';
									this.style.transform = 'translate3d('+(-moveLeft*this.offsetWidth)+'px,0,0)';
									upX = (-moveLeft*this.offsetWidth);
								 
								}
								
								//是否超出right
								//else if(upY<=lictH-liulH){
									//this.style.transition = '.2s';
									//this.style.transform = 'translate3d(0,'+(lictH-liulH)+'px,0)';
								//	upY = lictH-liulH;
								//}
								
						},false)
						
						
						//过度动画执行完毕 清除
						objLeft[i].addEventListener('transitionend',function (){
							this.style.transition = '';
			 
						})
						
						
						
					}
					 
					//上下手势
				
					for(;i<objTop.length;i++){
						objTop[i].i =i;
						objTop[i].addEventListener('touchstart',function (e){
							liulH = this.offsetHeight;
							this.style.transition = '';
							e.preventDefault();
							downY = e.touches[0].pageY;
							offGq = true;
 
							 
						},false)
						
						objTop[i].addEventListener('touchmove',function (e){			
 
							objLeft[0].removeEventListener('touchmove',objLeftMove,false);
							e.preventDefault();
							//如果歌曲内容过少，取消滑动	
							if(lictH>=liulH){return false;}
							upY = upY == undefined ? 0 : upY;
							moveY = e.touches[0].pageY;
							var mYdYuY = moveY-downY+upY;
							
							//有的设备 不移动 也会触发移动 如果移动较少 选取歌曲
							if(moveY-downY <= 2 && moveY-downY　>=0 || moveY-downY>=-2 && moveY-downY<=0){
								offGq = true;
								return false;
							}else{
								offGq = false;
							}
							
							
							this.style.transform = 'translate3d(0,'+(mYdYuY)+'px,0)';

							//记录上一次滚动位置
							this.upY = mYdYuY;
							 
						},false)
							
						objTop[i].addEventListener('touchend',function (e){
								 
								e.preventDefault();
								//上一次位置赋值
								upY = this.upY;
								//判断是否超出Top
								if(upY>=0){
									this.style.transition = '.2s';
									this.style.transform = 'translate3d(0,0,0)';
									upY = 0;
								}
								//是否超出bot
								else if(upY<=lictH-liulH){
									this.style.transition = '.2s';
									this.style.transform = 'translate3d(0,'+(lictH-liulH)+'px,0)';
									console.log(lictH);
									upY = lictH-liulH;
								}
								 
						},false)
						
						
						//过度动画执行完毕 清除
						objTop[i].addEventListener('transitionend',function (){
							this.style.transition = '';
 

						objLeft[0].addEventListener('touchmove',objLeftMove,false)
						})
						
						
						
					}

			}
			
			function ajax(obj){
						var ajax = new XMLHttpRequest;
						//发送路径
						//ajax.open('get','http://139.129.108.158/music/index.php/Admin/'+obj.url);	
						ajax.open('get',appMusic+'/Admin/'+obj.url);	
						ajax.onreadystatechange=function(){
							if(ajax.readyState==4){
								if(ajax.status==200){	
									var json = ajax.responseText;
									eval('json='+json); //字符串转对象
									obj.success(json);
									
								}else{
									console.log('error');
								}
							}
						}
						//发送数据
						ajax.send();
						
					}
			
			return {
				init : init
			}

		}
		
		
		var bfq  = new bfq();
		bfq.init();
		
}